# A general java project makefile
# Author: jerome
# create: 2023-07-30
# update: 2023-07-30
# version: 1.0

# Set the file name of your jar package:
JAR_PKG = work1.jar
# Set your entry point of your java app:
ENTRY_POINT = com.jerome.rmi.CalculatorServer
# Do you need the res directory? If your program has pictures, documents, etc.,
# It is best to put it in the res directory.
# yes: required; no: not required
RES_DIR = no

SOURCE_FILES = \
main/java/com/jerome/rmi/constants/RmiConstant.java \
main/java/com/jerome/rmi/enums/OperatorEnum.java \
main/java/com/jerome/rmi/enums/ScannerOperatorEnum.java \
main/java/com/jerome/rmi/util/MathUtil.java \
main/java/com/jerome/rmi/util/RegistryUtil.java \
main/java/com/jerome/rmi/Calculator.java \
main/java/com/jerome/rmi/CalculatorImplementation.java \
main/java/com/jerome/rmi/RemoteDefault.java \
main/java/com/jerome/rmi/RemoteDefaultImplementation.java \
main/java/com/jerome/rmi/CalculatorClient.java \
main/java/com/jerome/rmi/CalculatorServer.java \
main/java/com/jerome/rmi/test/ClientRunnable.java \
main/java/com/jerome/rmi/test/CalculatorClient4ExclusiveTest.java \
main/java/com/jerome/rmi/test/CalculatorClientSingleTest.java \
main/java/com/jerome/rmi/test/CalculatorClientTest.java \

# Set your java compiler here:
JAVAC = javac

JFLAGS = -encoding UTF-8

# make build: Compile and generate java classes in the bin directory.
# make clean: Clean up the compilation results for recompilation
# make rebuild: Clean up the compilation results and recompile.
# make run: After make, you can view the running results through make run.
# make jar: Generate an executable jar package.

#############下面的内容建议不要修改####################

vpath %.class bin
vpath %.java src

# show help message by default
Default:
	@echo "make new: new project, create src, bin, res dirs."
	@echo "make build: build project."
	@echo "make clean: clear classes generated."
	@echo "make rebuild: rebuild project."
	@echo "make run: run your app."
	@echo "make jar: package your project into a executable jar."

build: $(SOURCE_FILES:.java=.class)

# pattern rule
%.class: %.java
	$(JAVAC) -cp bin -d bin $(JFLAGS) $<

rebuild: clean build

.PHONY: new clean run jar

new:
ifeq ($(RES_DIR),yes)
	mkdir -pv src bin res
else
	mkdir -pv src bin
endif

clean:
	rm -frv bin/*

run:
	java -cp bin $(ENTRY_POINT)

jar:
ifeq ($(RES_DIR),yes)
	jar cvfe $(JAR_PKG) $(ENTRY_POINT)  -C bin . res
else
	jar cvfe $(JAR_PKG) $(ENTRY_POINT) -C bin .
endif
